import './index.scss'
import World from './world/world';
import AssestManager from './base/assest';
import { assestConfig } from './base/config'
import Helper from './base/helper';
import Light from './base/light';
import Model from './base/model'
import Env from './base/env'
import VConsole from 'vconsole';
new VConsole();
const init = async () => {
    const world = new World();
    await world.addAssests(new AssestManager(assestConfig), (progress: any) => {
        console.log(progress);
    });
    world
        .addComponent(Model.xbot(world))
        .addComponent(Env.floorMesh())
        .addLight(Light.spotMainLight())
        .addLight(Light.ambientLight())
        .setContactShadow()
        .start();

    let int = 0;
    let animations = ['agree', 'headShake', 'idle', 'run', 'sad_pose', 'sneak_pose', 'walk'];
    world.setAnimation('run');
    // (window as any).setAnimation = world.setAnimation.bind(world);
    (window as any).setAnimation = (str: any) => {
        console.log('setAnimation');
        console.log(str);
        if (int >= animations.length) int = 0;
        world.setAnimation(animations[int++]);
    }

    // setInterval(() => {
    //     if (int >= animations.length) int = 0;
    //     world.setAnimation(animations[int++]);
    // }, 1000)
}

init();